<!DOCTYPE html>
<html>
  <head>
    <title>Html5 Ajax 上传文件</title>
    <meta charset="utf-8">
  </head>
  <body>
    <form id="form1">
      <label>选择本地文件:
        <input type="file" name="file"/> 
      </label>
      <br />
      <input type="button" name="submit" value="上传"/>
    </form>
      <script src="../js/jquery-3.2.1.js"></script>
      <script>
        /*ajax上传文件*/
        $(":button").click(()=>{
            $.ajax({
                url:"upload_file.php",
                type:"post",
                data:new FormData($("#form1")[0]),
                contentType:false,
                processData:false
            });
        })
      </script>
    </body>
</html>